This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.
When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
# Load required packages
# install.packages("dplyr")
# install.packages("Hmisc")
library(dplyr)
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
library(Hmisc)
## Loading required package: lattice
## Loading required package: survival
## Loading required package: Formula
## Loading required package: ggplot2
##
## Attaching package: 'Hmisc'
## The following objects are masked from 'package:dplyr':
##
## src, summarize
## The following objects are masked from 'package:base':
##
## format.pval, units
library(ggplot2, quietly = TRUE, warn.conflicts = FALSE)
library(emmeans, quietly = TRUE, warn.conflicts = FALSE)
library(lsmeans, quietly = TRUE, warn.conflicts = FALSE)
## The 'lsmeans' package is now basically a front end for 'emmeans'.
## Users are encouraged to switch the rest of the way.
## See help('transition') for more information, including how to
## convert old 'lsmeans' objects and scripts to work with 'emmeans'.
library(effects, quietly = TRUE, warn.conflicts = FALSE)
## Use the command
## lattice::trellis.par.set(effectsTheme())
## to customize lattice options for effects plots.
## See ?effectsTheme for details.
library(nlme, quietly = TRUE, warn.conflicts = FALSE)
library(lme4, quietly = TRUE, warn.conflicts = FALSE)
library(lmerTest, quietly = TRUE, warn.conflicts = FALSE)
library(sjPlot, quietly = TRUE, warn.conflicts = FALSE)
## Registered S3 methods overwritten by 'parameters':
## method from
## as.double.parameters_kurtosis datawizard
## as.double.parameters_skewness datawizard
## as.double.parameters_smoothness datawizard
## as.numeric.parameters_kurtosis datawizard
## as.numeric.parameters_skewness datawizard
## as.numeric.parameters_smoothness datawizard
## print.parameters_distribution datawizard
## print.parameters_kurtosis datawizard
## print.parameters_skewness datawizard
## summary.parameters_kurtosis datawizard
## summary.parameters_skewness datawizard
library(stats, quietly = TRUE, warn.conflicts = FALSE)
library(dplyr, quietly = TRUE, warn.conflicts = FALSE)
ZOO <- read.csv(file = '/Users/aysuerdemir/Desktop/R workspace/ERP_Zoo/CrossSectional/Mix/ZOO.csv')
# Remove the added X variable after reading it back into R:
ZOO <- ZOO %>%
dplyr::select(-X)
# Display the first 6 rows of te final dataset:
head(ZOO)
## Subject StimTag Emotion Condition Laterality MeanAmp_P2 MeanAmp_N2
## 1 AE050318 NegGo Neg Go Left -8.2741357 -12.4529149
## 2 AE050318 NegGo Neg Go Midline -8.6567894 -17.6405009
## 3 AE050318 NegGo Neg Go Right -10.9978696 -17.0612959
## 4 AE050318 NegNoGo Neg NoGo Right 3.0738593 -0.6563204
## 5 AE050318 NegNoGo Neg NoGo Midline 0.1368089 -2.7636031
## 6 AE050318 NegNoGo Neg NoGo Left -10.2330683 -11.7855128
## MeanAmp_P3 Latency_P2 PeakAmp_P2 Latency_N2 PeakAmp_N2 Latency_P3 PeakAmp_P3
## 1 7.006061 200 -6.982536 368 -17.043367 512 9.862223
## 2 4.369997 212 -6.242593 352 -23.058663 612 6.037603
## 3 -1.012820 208 -8.224361 352 -20.626624 576 0.844127
## 4 0.449258 232 5.512485 400 -3.018455 508 3.116096
## 5 3.345500 252 3.300071 452 -5.257907 600 6.301873
## 6 2.221935 188 -8.637317 408 -12.417423 648 5.847591
## MeanAmp_N2P2 PeakAmp_N2P2 calculator_age_cve calculator_gender_cve race
## 1 -4.178779 -10.060831 38.1 0 2
## 2 -8.983711 -16.816070 38.1 0 2
## 3 -6.063426 -12.402263 38.1 0 2
## 4 -3.730180 -8.530940 38.1 0 2
## 5 -2.900412 -8.557978 38.1 0 2
## 6 -1.552445 -3.780106 38.1 0 2
## ethnicity calculator_talkergroup_parent tso_calculated
## 1 0 1 1.9
## 2 0 1 1.9
## 3 0 1 1.9
## 4 0 1 1.9
## 5 0 1 1.9
## 6 0 1 1.9
## disfluency_sldper100words ssi_total disfluency_sldper100words_final
## 1 12 23 12
## 2 12 23 12
## 3 12 23 12
## 4 12 23 12
## 5 12 23 12
## 6 12 23 12
## talkergroup_final gfta_standard ppvt_standard evt_standard teld_rec_standard
## 1 1 121 126 123 146
## 2 1 121 126 123 146
## 3 1 121 126 123 146
## 4 1 121 126 123 146
## 5 1 121 126 123 146
## 6 1 121 126 123 146
## teld_exp_standard teld_spokenlang_standard tocs_1_total tocs_2_total
## 1 135 149 22 6
## 2 135 149 22 6
## 3 135 149 22 6
## 4 135 149 22 6
## 5 135 149 22 6
## 6 135 149 22 6
## tcs_total eprime_condorder_zootask cve_comments comments_tasks handedness_zoo
## 1 25 1 NA
## 2 25 1 NA
## 3 25 1 NA
## 4 25 1 NA
## 5 25 1 NA
## 6 25 1 NA
## accuracy premature_responses RT_proper RT_all_go TrialNum
## 1 75.83333 9.90099 774.044 706.0297 31
## 2 75.83333 9.90099 774.044 706.0297 31
## 3 75.83333 9.90099 774.044 706.0297 31
## 4 57.50000 23.52941 566.000 NA 10
## 5 57.50000 23.52941 566.000 NA 10
## 6 57.50000 23.52941 566.000 NA 10
ZOO_good <- read.csv(file = '/Users/aysuerdemir/Desktop/R workspace/ERP_Zoo/CrossSectional/Mix/ZOO_good.csv')
# Remove the added X variable after reading it back into R:
ZOO_good <- ZOO_good %>%
dplyr::select(-X)
# Display the first 6 rows of te final dataset:
head(ZOO_good)
## Subject StimTag Emotion Condition Laterality MeanAmp_P2 MeanAmp_N2
## 1 AE050318 NegGo Neg Go Left -8.2741357 -12.4529149
## 2 AE050318 NegGo Neg Go Midline -8.6567894 -17.6405009
## 3 AE050318 NegGo Neg Go Right -10.9978696 -17.0612959
## 4 AE050318 NegNoGo Neg NoGo Right 3.0738593 -0.6563204
## 5 AE050318 NegNoGo Neg NoGo Midline 0.1368089 -2.7636031
## 6 AE050318 NegNoGo Neg NoGo Left -10.2330683 -11.7855128
## MeanAmp_P3 Latency_P2 PeakAmp_P2 Latency_N2 PeakAmp_N2 Latency_P3 PeakAmp_P3
## 1 7.006061 200 -6.982536 368 -17.043367 512 9.862223
## 2 4.369997 212 -6.242593 352 -23.058663 612 6.037603
## 3 -1.012820 208 -8.224361 352 -20.626624 576 0.844127
## 4 0.449258 232 5.512485 400 -3.018455 508 3.116096
## 5 3.345500 252 3.300071 452 -5.257907 600 6.301873
## 6 2.221935 188 -8.637317 408 -12.417423 648 5.847591
## MeanAmp_N2P2 PeakAmp_N2P2 calculator_age_cve calculator_gender_cve race
## 1 -4.178779 -10.060831 38.1 0 2
## 2 -8.983711 -16.816070 38.1 0 2
## 3 -6.063426 -12.402263 38.1 0 2
## 4 -3.730180 -8.530940 38.1 0 2
## 5 -2.900412 -8.557978 38.1 0 2
## 6 -1.552445 -3.780106 38.1 0 2
## ethnicity calculator_talkergroup_parent tso_calculated
## 1 0 1 1.9
## 2 0 1 1.9
## 3 0 1 1.9
## 4 0 1 1.9
## 5 0 1 1.9
## 6 0 1 1.9
## disfluency_sldper100words ssi_total disfluency_sldper100words_final
## 1 12 23 12
## 2 12 23 12
## 3 12 23 12
## 4 12 23 12
## 5 12 23 12
## 6 12 23 12
## talkergroup_final gfta_standard ppvt_standard evt_standard teld_rec_standard
## 1 1 121 126 123 146
## 2 1 121 126 123 146
## 3 1 121 126 123 146
## 4 1 121 126 123 146
## 5 1 121 126 123 146
## 6 1 121 126 123 146
## teld_exp_standard teld_spokenlang_standard tocs_1_total tocs_2_total
## 1 135 149 22 6
## 2 135 149 22 6
## 3 135 149 22 6
## 4 135 149 22 6
## 5 135 149 22 6
## 6 135 149 22 6
## tcs_total eprime_condorder_zootask cve_comments comments_tasks handedness_zoo
## 1 25 1 NA
## 2 25 1 NA
## 3 25 1 NA
## 4 25 1 NA
## 5 25 1 NA
## 6 25 1 NA
## accuracy premature_responses RT_proper RT_all_go TrialNum
## 1 75.83333 9.90099 774.044 706.0297 31
## 2 75.83333 9.90099 774.044 706.0297 31
## 3 75.83333 9.90099 774.044 706.0297 31
## 4 57.50000 23.52941 566.000 NA 10
## 5 57.50000 23.52941 566.000 NA 10
## 6 57.50000 23.52941 566.000 NA 10
print(names(ZOO_good))
## [1] "Subject" "StimTag"
## [3] "Emotion" "Condition"
## [5] "Laterality" "MeanAmp_P2"
## [7] "MeanAmp_N2" "MeanAmp_P3"
## [9] "Latency_P2" "PeakAmp_P2"
## [11] "Latency_N2" "PeakAmp_N2"
## [13] "Latency_P3" "PeakAmp_P3"
## [15] "MeanAmp_N2P2" "PeakAmp_N2P2"
## [17] "calculator_age_cve" "calculator_gender_cve"
## [19] "race" "ethnicity"
## [21] "calculator_talkergroup_parent" "tso_calculated"
## [23] "disfluency_sldper100words" "ssi_total"
## [25] "disfluency_sldper100words_final" "talkergroup_final"
## [27] "gfta_standard" "ppvt_standard"
## [29] "evt_standard" "teld_rec_standard"
## [31] "teld_exp_standard" "teld_spokenlang_standard"
## [33] "tocs_1_total" "tocs_2_total"
## [35] "tcs_total" "eprime_condorder_zootask"
## [37] "cve_comments" "comments_tasks"
## [39] "handedness_zoo" "accuracy"
## [41] "premature_responses" "RT_proper"
## [43] "RT_all_go" "TrialNum"
# DATAFRAME FOR ERP and BEHAVIORAL ANALYSES:
ZOO_FCz_Pz <- subset(ZOO_good, (Laterality == "Midline"))
rownames(ZOO_FCz_Pz) <- NULL # reset index
# DATAFRAME FOR AGE-GENDER ANALYSE ANALYSES:
# Create a dataset with only 1 entry for each subject:
# Pick one condition - randomly - because we are only working on age and gender for this one:
ZOO_age_gender <- subset(ZOO_FCz_Pz, (StimTag == "NegGo"))
rownames(ZOO_age_gender) <- NULL # reset index
# Give Age, Gender and Count Summary Statistics for each Group:
ZOO_age_gender_summary <-
ZOO_age_gender %>%
group_by(talkergroup_final) %>%
summarise(
age = mean(calculator_age_cve, na.rm = TRUE),
min_age = min(calculator_age_cve, na.rm = TRUE),
max_age = max(calculator_age_cve, na.rm = TRUE),
gender = mean(calculator_gender_cve, na.rm = TRUE),
SD_age = sd(calculator_age_cve, na.rm = TRUE),
Count_kids = n_distinct(Subject)
)
print(ZOO_age_gender_summary)
## # A tibble: 2 × 7
## talkergroup_final age min_age max_age gender SD_age Count_kids
## <int> <dbl> <dbl> <dbl> <dbl> <dbl> <int>
## 1 0 57.5 38 81.7 0.548 12.6 42
## 2 1 58.4 36.6 79.4 0.595 13.1 37
# Histogram of Age across all participants
hist(ZOO_age_gender$calculator_age_cve,
main = "Histogram of Age",
xlab = "age in months",
ylab = "Frequency",
col = "blue", # Color of bars
border = "black", # Border color of bars
# xlim = c(min_value, max_value), # Adjust the x-axis limits if needed
breaks = 12)
# print(quantile(ZOO$calculator_age_cve, 0.50, na.rm = TRUE),)
# CREATE TWO PLOTS FOR CWS AND CWNS
# Create a new plot
par(mfrow=c(1,2)) # This sets up a 1x2 grid for side-by-side histograms
# Histogram for talkergroup_final == 1
hist(ZOO_age_gender$calculator_age_cve[ZOO_age_gender$talkergroup_final == 0],
main = "Histogram for CWNS",
xlab = "age in months",
ylab = "Frequency",
col = "blue",
border = "black",
xlim = c(30, 100),
breaks = 12)
# Histogram for talkergroup_final == 2
hist(ZOO_age_gender$calculator_age_cve[ZOO_age_gender$talkergroup_final == 1],
main = "Histogram for CWS",
xlab = "age in months",
ylab = "Frequency",
col = "red", # Use a different color for the second group
border = "black",
xlim = c(30, 100),
breaks = 12)
# Reset the plotting to a single plot
par(mfrow=c(1,1))
# MAKE SURE AGE DOES NOT DIFFER BETWEEN GROUPS USING ANOVA
model <- aov (calculator_age_cve ~ talkergroup_final, data = ZOO_age_gender)
anova(model)
## Analysis of Variance Table
##
## Response: calculator_age_cve
## Df Sum Sq Mean Sq F value Pr(>F)
## talkergroup_final 1 16 15.972 0.0969 0.7564
## Residuals 77 12688 164.786
# MAKE SURE AGE DOES NOT DIFFER BETWEEN GROUPS USING T-Test
# Subset the data into two groups based on talkergroup_final
group_CWNS <- ZOO_age_gender$calculator_age_cve[ZOO_age_gender$talkergroup_final == 0]
group_CWS <- ZOO_age_gender$calculator_age_cve[ZOO_age_gender$talkergroup_final == 1]
# Perform a two-sample t-test
t_test_result <- t.test(group_CWNS, group_CWS, alternative = "two.sided")
# Display the t-test result
print(t_test_result)
##
## Welch Two Sample t-test
##
## data: group_CWNS and group_CWS
## t = -0.31049, df = 74.829, p-value = 0.757
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## -6.682676 4.880488
## sample estimates:
## mean of x mean of y
## 57.48810 58.38919
# Histogram of Accuracy, premature_responses, and RT_proper
summary_behavioral_hist <-
ZOO_FCz_Pz %>%
group_by(Subject, talkergroup_final, StimTag) %>%
summarise(Average_accuracy = mean(accuracy, na.rm = TRUE),
Average_premature_responses = mean(premature_responses, na.rm = TRUE),
Average_RT = mean(RT_proper, na.rm = TRUE))
## `summarise()` has grouped output by 'Subject', 'talkergroup_final'. You can
## override using the `.groups` argument.
print(summary_behavioral_hist)
## # A tibble: 316 × 6
## # Groups: Subject, talkergroup_final [79]
## Subject talkergroup_final StimTag Average_accuracy Average_premature_resp…¹
## <chr> <int> <chr> <dbl> <dbl>
## 1 AE050318 1 NegGo 75.8 9.90
## 2 AE050318 1 NegNoGo 57.5 23.5
## 3 AE050318 1 NeutGo 90 0.917
## 4 AE050318 1 NeutNoGo 70 16.7
## 5 AH101121 0 NegGo 99.2 0
## 6 AH101121 0 NegNoGo 87.5 0
## 7 AH101121 0 NeutGo 100 0
## 8 AH101121 0 NeutNoGo 80 0
## 9 AK022218 0 NegGo 90 0.917
## 10 AK022218 0 NegNoGo 95 0
## # ℹ 306 more rows
## # ℹ abbreviated name: ¹Average_premature_responses
## # ℹ 1 more variable: Average_RT <dbl>
# Accuracy Histogram:
# Create a new plot
par(mfrow=c(1,2)) # This sets up a 1x2 grid for side-by-side histograms
# Histogram for talkergroup_final == 0
hist(summary_behavioral_hist$Average_accuracy[summary_behavioral_hist$talkergroup_final == 0],
main = "Histogram for CWNS",
xlab = "accuracy",
ylab = "Frequency",
col = "blue",
border = "black",
xlim = c(0, 100),
ylim = c(0, 50),
breaks = 12)
# Histogram for talkergroup_final == 1
hist(summary_behavioral_hist$Average_accuracy[summary_behavioral_hist$talkergroup_final == 1],
main = "Histogram for CWS",
xlab = "accuracy",
ylab = "Frequency",
col = "red", # Use a different color for the second group
border = "black",
xlim = c(0, 100),
ylim = c(0, 50),
breaks = 12)
# Reset the plotting to a single plot
par(mfrow=c(1,1))
# Scatterplot of all accuracy across all participants
scatterplot <- ggplot(summary_behavioral_hist, aes(x = Subject, y = Average_accuracy, color = StimTag)) +
geom_point() +
scale_y_continuous(limits = c(0, 100), breaks = seq(0, 100, by = 10))
plot(scatterplot)
# Premature responses Histogram:
# Create a new plot
par(mfrow=c(1,2))
# Histogram for talkergroup_final == 0
hist(summary_behavioral_hist$Average_premature_responses[summary_behavioral_hist$talkergroup_final == 0],
main = "Histogram for CWNS",
xlab = "premature_responses",
ylab = "Frequency",
col = "blue",
border = "black",
xlim = c(0, 50),
ylim = c(0, 150),
breaks = 12)
# Histogram for talkergroup_final == 1
hist(summary_behavioral_hist$Average_premature_responses[summary_behavioral_hist$talkergroup_final == 1],
main = "Histogram for CWS",
xlab = "premature_responses",
ylab = "Frequency",
col = "red", # Use a different color for the second group
border = "black",
xlim = c(0, 50),
ylim = c(0, 150),
breaks = 12)
# Reset the plotting to a single plot
par(mfrow=c(1,1))
# Scatterplot of all accuracy across all participants
scatterplot <- ggplot(summary_behavioral_hist, aes(x = Subject, y = Average_premature_responses, color = StimTag)) +
geom_point() +
scale_y_continuous(limits = c(0, 50), breaks = seq(0, 50, by = 10))
plot(scatterplot)
## Warning: Removed 5 rows containing missing values (`geom_point()`).
#Reaction Time Histogram:
# Create a new plot
par(mfrow=c(1,2))
# Histogram for talkergroup_final == 0
hist(summary_behavioral_hist$Average_RT[summary_behavioral_hist$talkergroup_final == 0],
main = "Histogram for CWNS",
xlab = "reaction_time",
ylab = "Frequency",
col = "blue",
border = "black",
xlim = c(100, 2000),
ylim = c(0, 50),
breaks = 12)
# Histogram for talkergroup_final == 1
hist(summary_behavioral_hist$Average_RT[summary_behavioral_hist$talkergroup_final == 1],
main = "Histogram for CWS",
xlab = "reaction_time",
ylab = "Frequency",
col = "red", # Use a different color for the second group
border = "black",
xlim = c(100, 2000),
ylim = c(0, 50),
breaks = 12)
# Reset the plotting to a single plot
par(mfrow=c(1,1))
# Scatterplot of all reaction time across all participants
scatterplot <- ggplot(summary_behavioral_hist, aes(x = Subject, y = Average_RT, color = StimTag)) +
geom_point() +
scale_y_continuous(limits = c(200, 2000), breaks = seq(200, 2000, by = 200))
plot(scatterplot)
## Warning: Removed 5 rows containing missing values (`geom_point()`).
# Create the Dataframe to get the behavioral data
summary_behavioral <-
ZOO_FCz_Pz%>%
group_by(talkergroup_final, Emotion, Condition) %>%
summarise(
Average_accuracy = mean(accuracy, na.rm = TRUE),
SEM_accuracy = sd(accuracy, na.rm = TRUE) / sqrt(n()),
Average_premature_responses = mean(premature_responses, na.rm = TRUE),
SEM_premature_responses = sd(premature_responses, na.rm = TRUE) / sqrt(n()),
Average_RT_proper = mean(RT_proper, na.rm = TRUE),
SEM_RT_proper = sd(RT_proper, na.rm = TRUE) / sqrt(n()),
)
## `summarise()` has grouped output by 'talkergroup_final', 'Emotion'. You can
## override using the `.groups` argument.
# Rename some factors for better visuals:
summary_behavioral$talkergroup_final <- factor(summary_behavioral$talkergroup_final, levels = c(0, 1), labels = c("CWNS", "CWS"))
summary_behavioral$Emotion <- factor(summary_behavioral$Emotion, levels = c("Neg", "Neut"), labels = c("Affective", "Neutral"))
# BAR PLOT FOR ACCURACY
bar_plot <- ggplot(summary_behavioral, aes(x = Emotion, y = Average_accuracy, fill = Condition)) +
geom_bar(stat = "identity", position = "dodge", width = 0.7) +
geom_errorbar(aes(ymin = Average_accuracy - SEM_accuracy, ymax = Average_accuracy + SEM_accuracy), width = 0.2, position = position_dodge(width = 0.7)) +
labs(x = "Emotion", y = "Average Accuracy (%)") +
facet_grid(. ~ talkergroup_final) +
theme_minimal() +
theme(
axis.text = element_text(size = 14, color = "black"),
axis.title = element_text(size = 14),
legend.title =element_blank(),
legend.text = element_text(size = 14),
plot.title = element_text(hjust = 0.5, size = 14, face = "bold", vjust = 2),
strip.text = element_text(size = 14, face = "bold")) +
scale_fill_manual(values = c("royalblue2", "orangered", "royalblue2", "orangered", "royalblue2", "orangered", "royalblue2", "orangered"))
# ggtitle("Average Accuracy by Emotion and Condition for CWS and CWNS")
bar_plot <- bar_plot + coord_cartesian(ylim = c(50, 100))
print(bar_plot)
# BAR PLOT FOR PREMATURE RESPONSES
bar_plot <- ggplot(summary_behavioral, aes(x = Emotion, y = Average_premature_responses, fill = Condition)) +
geom_bar(stat = "identity", position = "dodge", width = 0.7) +
geom_errorbar(aes(ymin = Average_premature_responses - SEM_premature_responses, ymax = Average_premature_responses + SEM_premature_responses), width = 0.2, position = position_dodge(width = 0.7)) +
labs(x = "Emotion", y = "Average_premature_responses (%)") +
facet_grid(. ~ talkergroup_final) +
theme_minimal() +
theme(
axis.text = element_text(size = 14, color = "black"),
axis.title = element_text(size = 14),
legend.title =element_blank(),
legend.text = element_text(size = 14),
plot.title = element_text(hjust = 0.5, size = 14, face = "bold", vjust = 2),
strip.text = element_text(size = 14, face = "bold")) +
scale_fill_manual(values = c("royalblue2", "orangered", "royalblue2", "orangered", "royalblue2", "orangered", "royalblue2", "orangered"))
# ggtitle("Average Accuracy by Emotion and Condition for CWS and CWNS")
bar_plot <- bar_plot + coord_cartesian(ylim = c(0, 10))
print(bar_plot)
# BAR PLOT FOR REACTION TIME - both go and nogo
bar_plot <- ggplot(summary_behavioral, aes(x = Emotion, y = Average_RT_proper, fill = Condition)) +
geom_bar(stat = "identity", position = "dodge", width = 0.7) +
geom_errorbar(aes(ymin = Average_RT_proper - SEM_RT_proper, ymax = Average_RT_proper + SEM_RT_proper), width = 0.2, position = position_dodge(width = 0.7)) +
labs(x = "Emotion", y = "Average Reaction Time (ms)") +
facet_grid(. ~ talkergroup_final) +
theme_minimal() +
theme(
axis.text = element_text(size = 14, color = "black"),
axis.title = element_text(size = 14),
legend.title =element_blank(),
legend.text = element_text(size = 14),
plot.title = element_text(hjust = 0.5, size = 14, face = "bold", vjust = 2),
strip.text = element_text(size = 14, face = "bold")) +
scale_fill_manual(values = c("royalblue2", "orangered", "royalblue2", "orangered", "royalblue2", "orangered", "royalblue2", "orangered"))
# ggtitle("Average Accuracy by Emotion and Condition for CWS and CWNS")
bar_plot <- bar_plot + coord_cartesian(ylim = c(500, 850))
print(bar_plot)
# BAR PLOT FOR REACTION TIME - GO ONLY
summary_behavioral_Go <- subset(summary_behavioral, Condition == "Go")
bar_plot <- ggplot(summary_behavioral_Go, aes(x = Emotion, y = Average_RT_proper)) +
geom_bar(stat = "identity", position = "dodge", width = 0.5, fill ='royalblue2') +
geom_errorbar(aes(ymin = Average_RT_proper - SEM_RT_proper, ymax = Average_RT_proper + SEM_RT_proper), width = 0.2, position = position_dodge(width = 0.9)) +
labs(x = "Emotion", y = "Average Reaction Time (ms)") +
facet_grid(. ~ talkergroup_final) +
theme_minimal() +
theme(
axis.text = element_text(size = 14, color = "black"),
axis.title = element_text(size = 14),
legend.title =element_blank(),
legend.text = element_text(size = 14),
plot.title = element_text(hjust = 0.5, size = 14, face = "bold", vjust = 2),
strip.text = element_text(size = 14, face = "bold"))
# ggtitle("Average Accuracy by Emotion and Condition for CWS and CWNS")
bar_plot <- bar_plot + coord_cartesian(ylim = c(500, 850))
print(bar_plot)
# ACCURACY
model1 <- lmer(accuracy ~ talkergroup_final*Emotion*Condition +
calculator_gender_cve + calculator_age_cve + (1|Subject), data = ZOO_FCz_Pz, REML = TRUE)
anova(model1)
## Type III Analysis of Variance Table with Satterthwaite's method
## Sum Sq Mean Sq NumDF DenDF F value
## talkergroup_final 268.0 268.0 1 75 2.8230
## Emotion 43.4 43.4 1 231 0.4573
## Condition 10044.5 10044.5 1 231 105.8123
## calculator_gender_cve 75.3 75.3 1 75 0.7931
## calculator_age_cve 604.9 604.9 1 75 6.3723
## talkergroup_final:Emotion 5.4 5.4 1 231 0.0567
## talkergroup_final:Condition 109.8 109.8 1 231 1.1570
## Emotion:Condition 43.7 43.7 1 231 0.4600
## talkergroup_final:Emotion:Condition 84.3 84.3 1 231 0.8879
## Pr(>F)
## talkergroup_final 0.09708 .
## Emotion 0.49955
## Condition < 2e-16 ***
## calculator_gender_cve 0.37601
## calculator_age_cve 0.01371 *
## talkergroup_final:Emotion 0.81202
## talkergroup_final:Condition 0.28320
## Emotion:Condition 0.49829
## talkergroup_final:Emotion:Condition 0.34703
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
plot_model(model1, type="pred", terms = c("Emotion" , "Condition", "talkergroup_final"))
emmeans_result <- emmeans(model1, pairwise ~ talkergroup_final | Emotion | Condition) # Tukey is default
pairs(emmeans_result, adjust= "none", simple = "each") # adjust = "bonferroni"
## $emmeans
## $`simple contrasts for talkergroup_final`
## Emotion = Neg, Condition = Go:
## contrast estimate SE df t.ratio p.value
## 0 - 1 2.57 2.6 242 0.990 0.3234
##
## Emotion = Neut, Condition = Go:
## contrast estimate SE df t.ratio p.value
## 0 - 1 1.03 2.6 242 0.395 0.6932
##
## Emotion = Neg, Condition = NoGo:
## contrast estimate SE df t.ratio p.value
## 0 - 1 2.87 2.6 242 1.102 0.2715
##
## Emotion = Neut, Condition = NoGo:
## contrast estimate SE df t.ratio p.value
## 0 - 1 5.46 2.6 242 2.099 0.0369
##
## Results are averaged over the levels of: calculator_gender_cve
## Degrees-of-freedom method: kenward-roger
##
## $`simple contrasts for Emotion`
## talkergroup_final = 0, Condition = Go:
## contrast estimate SE df t.ratio p.value
## Neg - Neut 2.03636 2.13 231 0.958 0.3392
##
## talkergroup_final = 1, Condition = Go:
## contrast estimate SE df t.ratio p.value
## Neg - Neut 0.48940 2.27 231 0.216 0.8291
##
## talkergroup_final = 0, Condition = NoGo:
## contrast estimate SE df t.ratio p.value
## Neg - Neut -0.00298 2.13 231 -0.001 0.9989
##
## talkergroup_final = 1, Condition = NoGo:
## contrast estimate SE df t.ratio p.value
## Neg - Neut 2.59005 2.27 231 1.143 0.2541
##
## Results are averaged over the levels of: calculator_gender_cve
## Degrees-of-freedom method: kenward-roger
##
## $`simple contrasts for Condition`
## talkergroup_final = 0, Emotion = Neg:
## contrast estimate SE df t.ratio p.value
## Go - NoGo 16.5 2.13 231 7.753 <.0001
##
## talkergroup_final = 1, Emotion = Neg:
## contrast estimate SE df t.ratio p.value
## Go - NoGo 16.8 2.27 231 7.406 <.0001
##
## talkergroup_final = 0, Emotion = Neut:
## contrast estimate SE df t.ratio p.value
## Go - NoGo 14.4 2.13 231 6.794 <.0001
##
## talkergroup_final = 1, Emotion = Neut:
## contrast estimate SE df t.ratio p.value
## Go - NoGo 18.9 2.27 231 8.334 <.0001
##
## Results are averaged over the levels of: calculator_gender_cve
## Degrees-of-freedom method: kenward-roger
##
##
## $contrasts
## $`simple contrasts for contrast`
## Emotion = Neg, Condition = Go:
## contrast estimate SE df z.ratio p.value
## (nothing) nonEst NA NA NA NA
##
## Emotion = Neut, Condition = Go:
## contrast estimate SE df z.ratio p.value
## (nothing) nonEst NA NA NA NA
##
## Emotion = Neg, Condition = NoGo:
## contrast estimate SE df z.ratio p.value
## (nothing) nonEst NA NA NA NA
##
## Emotion = Neut, Condition = NoGo:
## contrast estimate SE df z.ratio p.value
## (nothing) nonEst NA NA NA NA
##
## Results are averaged over the levels of: calculator_gender_cve
## Degrees-of-freedom method: kenward-roger
##
## $`simple contrasts for Emotion`
## contrast = 0 - 1, Condition = Go:
## contrast1 estimate SE df t.ratio p.value
## Neg - Neut 1.55 3.11 231 0.498 0.6190
##
## contrast = 0 - 1, Condition = NoGo:
## contrast1 estimate SE df t.ratio p.value
## Neg - Neut -2.59 3.11 231 -0.835 0.4048
##
## Results are averaged over the levels of: calculator_gender_cve
## Degrees-of-freedom method: kenward-roger
##
## $`simple contrasts for Condition`
## contrast = 0 - 1, Emotion = Neg:
## contrast1 estimate SE df t.ratio p.value
## Go - NoGo -0.293 3.11 231 -0.094 0.9250
##
## contrast = 0 - 1, Emotion = Neut:
## contrast1 estimate SE df t.ratio p.value
## Go - NoGo -4.433 3.11 231 -1.427 0.1550
##
## Results are averaged over the levels of: calculator_gender_cve
## Degrees-of-freedom method: kenward-roger
emmeans_resultCondition <- emmeans(model1, pairwise ~ Condition)
## NOTE: Results may be misleading due to involvement in interactions
emmeans_resultCondition
## $emmeans
## Condition emmean SE df lower.CL upper.CL
## Go 92.0 1.05 136 89.9 94.1
## NoGo 75.3 1.05 136 73.3 77.4
##
## Results are averaged over the levels of: talkergroup_final, Emotion, calculator_gender_cve
## Degrees-of-freedom method: kenward-roger
## Confidence level used: 0.95
##
## $contrasts
## contrast estimate SE df t.ratio p.value
## Go - NoGo 16.6 1.1 231 15.155 <.0001
##
## Results are averaged over the levels of: talkergroup_final, Emotion, calculator_gender_cve
## Degrees-of-freedom method: kenward-roger
emmeans_resulttalkergroupEmotion <- emmeans(model1, pairwise ~ talkergroup_final|Emotion)
## NOTE: Results may be misleading due to involvement in interactions
emmeans_resulttalkergroupEmotion
## $emmeans
## Emotion = Neg:
## talkergroup_final emmean SE df lower.CL upper.CL
## 0 85.7 1.43 137 82.8 88.5
## 1 82.9 1.53 136 79.9 86.0
##
## Emotion = Neut:
## talkergroup_final emmean SE df lower.CL upper.CL
## 0 84.6 1.43 137 81.8 87.5
## 1 81.4 1.53 136 78.4 84.4
##
## Results are averaged over the levels of: Condition, calculator_gender_cve
## Degrees-of-freedom method: kenward-roger
## Confidence level used: 0.95
##
## $contrasts
## Emotion = Neg:
## contrast estimate SE df t.ratio p.value
## 0 - 1 2.72 2.09 137 1.304 0.1946
##
## Emotion = Neut:
## contrast estimate SE df t.ratio p.value
## 0 - 1 3.24 2.09 137 1.554 0.1225
##
## Results are averaged over the levels of: Condition, calculator_gender_cve
## Degrees-of-freedom method: kenward-roger
pairs(emmeans_resulttalkergroupEmotion, adjust = "none", simple = "each")
## $emmeans
## $`simple contrasts for talkergroup_final`
## Emotion = Neg:
## contrast estimate SE df t.ratio p.value
## 0 - 1 2.72 2.09 137 1.304 0.1946
##
## Emotion = Neut:
## contrast estimate SE df t.ratio p.value
## 0 - 1 3.24 2.09 137 1.554 0.1225
##
## Results are averaged over the levels of: Condition, calculator_gender_cve
## Degrees-of-freedom method: kenward-roger
##
## $`simple contrasts for Emotion`
## talkergroup_final = 0:
## contrast estimate SE df t.ratio p.value
## Neg - Neut 1.02 1.5 231 0.676 0.4995
##
## talkergroup_final = 1:
## contrast estimate SE df t.ratio p.value
## Neg - Neut 1.54 1.6 231 0.961 0.3374
##
## Results are averaged over the levels of: Condition, calculator_gender_cve
## Degrees-of-freedom method: kenward-roger
##
##
## $contrasts
## $`simple contrasts for contrast`
## Emotion = Neg:
## contrast estimate SE df z.ratio p.value
## (nothing) nonEst NA NA NA NA
##
## Emotion = Neut:
## contrast estimate SE df z.ratio p.value
## (nothing) nonEst NA NA NA NA
##
## Results are averaged over the levels of: Condition, calculator_gender_cve
## Degrees-of-freedom method: kenward-roger
##
## $`simple contrasts for Emotion`
## contrast = 0 - 1:
## contrast1 estimate SE df t.ratio p.value
## Neg - Neut -0.523 2.2 231 -0.238 0.8120
##
## Results are averaged over the levels of: Condition, calculator_gender_cve
## Degrees-of-freedom method: kenward-roger
emmeans_resulttalkergroup <- emmeans(model1, pairwise ~ talkergroup_final)
## NOTE: Results may be misleading due to involvement in interactions
emmeans_resulttalkergroup
## $emmeans
## talkergroup_final emmean SE df lower.CL upper.CL
## 0 85.2 1.22 75 82.7 87.6
## 1 82.2 1.30 75 79.6 84.8
##
## Results are averaged over the levels of: Emotion, Condition, calculator_gender_cve
## Degrees-of-freedom method: kenward-roger
## Confidence level used: 0.95
##
## $contrasts
## contrast estimate SE df t.ratio p.value
## 0 - 1 2.98 1.78 75 1.680 0.0971
##
## Results are averaged over the levels of: Emotion, Condition, calculator_gender_cve
## Degrees-of-freedom method: kenward-roger
emmeans_resulttalkergroupCond <- emmeans(model1, pairwise ~ talkergroup_final|Condition)
## NOTE: Results may be misleading due to involvement in interactions
emmeans_resulttalkergroupCond
## $emmeans
## Condition = Go:
## talkergroup_final emmean SE df lower.CL upper.CL
## 0 92.9 1.43 137 90.1 95.7
## 1 91.1 1.53 136 88.1 94.1
##
## Condition = NoGo:
## talkergroup_final emmean SE df lower.CL upper.CL
## 0 77.4 1.43 137 74.6 80.3
## 1 73.3 1.53 136 70.2 76.3
##
## Results are averaged over the levels of: Emotion, calculator_gender_cve
## Degrees-of-freedom method: kenward-roger
## Confidence level used: 0.95
##
## $contrasts
## Condition = Go:
## contrast estimate SE df t.ratio p.value
## 0 - 1 1.80 2.09 137 0.863 0.3897
##
## Condition = NoGo:
## contrast estimate SE df t.ratio p.value
## 0 - 1 4.16 2.09 137 1.995 0.0481
##
## Results are averaged over the levels of: Emotion, calculator_gender_cve
## Degrees-of-freedom method: kenward-roger
pairs(emmeans_resulttalkergroupCond, adjust = "none", simple = "each")
## $emmeans
## $`simple contrasts for talkergroup_final`
## Condition = Go:
## contrast estimate SE df t.ratio p.value
## 0 - 1 1.80 2.09 137 0.863 0.3897
##
## Condition = NoGo:
## contrast estimate SE df t.ratio p.value
## 0 - 1 4.16 2.09 137 1.995 0.0481
##
## Results are averaged over the levels of: Emotion, calculator_gender_cve
## Degrees-of-freedom method: kenward-roger
##
## $`simple contrasts for Condition`
## talkergroup_final = 0:
## contrast estimate SE df t.ratio p.value
## Go - NoGo 15.5 1.5 231 10.287 <.0001
##
## talkergroup_final = 1:
## contrast estimate SE df t.ratio p.value
## Go - NoGo 17.8 1.6 231 11.130 <.0001
##
## Results are averaged over the levels of: Emotion, calculator_gender_cve
## Degrees-of-freedom method: kenward-roger
##
##
## $contrasts
## $`simple contrasts for contrast`
## Condition = Go:
## contrast estimate SE df z.ratio p.value
## (nothing) nonEst NA NA NA NA
##
## Condition = NoGo:
## contrast estimate SE df z.ratio p.value
## (nothing) nonEst NA NA NA NA
##
## Results are averaged over the levels of: Emotion, calculator_gender_cve
## Degrees-of-freedom method: kenward-roger
##
## $`simple contrasts for Condition`
## contrast = 0 - 1:
## contrast1 estimate SE df t.ratio p.value
## Go - NoGo -2.36 2.2 231 -1.076 0.2832
##
## Results are averaged over the levels of: Emotion, calculator_gender_cve
## Degrees-of-freedom method: kenward-roger
emmeans_resulttalkergroupCondEmo <- emmeans(model1, pairwise ~ talkergroup_final|Condition|Emotion)
emmeans_resulttalkergroupCondEmo
## $emmeans
## Condition = Go, Emotion = Neg:
## talkergroup_final emmean SE df lower.CL upper.CL
## 0 93.9 1.78 242 90.4 97.4
## 1 91.3 1.90 241 87.6 95.1
##
## Condition = NoGo, Emotion = Neg:
## talkergroup_final emmean SE df lower.CL upper.CL
## 0 77.4 1.78 242 73.9 80.9
## 1 74.6 1.90 241 70.8 78.3
##
## Condition = Go, Emotion = Neut:
## talkergroup_final emmean SE df lower.CL upper.CL
## 0 91.9 1.78 242 88.4 95.4
## 1 90.8 1.90 241 87.1 94.6
##
## Condition = NoGo, Emotion = Neut:
## talkergroup_final emmean SE df lower.CL upper.CL
## 0 77.4 1.78 242 73.9 80.9
## 1 72.0 1.90 241 68.2 75.7
##
## Results are averaged over the levels of: calculator_gender_cve
## Degrees-of-freedom method: kenward-roger
## Confidence level used: 0.95
##
## $contrasts
## Condition = Go, Emotion = Neg:
## contrast estimate SE df t.ratio p.value
## 0 - 1 2.57 2.6 242 0.990 0.3234
##
## Condition = NoGo, Emotion = Neg:
## contrast estimate SE df t.ratio p.value
## 0 - 1 2.87 2.6 242 1.102 0.2715
##
## Condition = Go, Emotion = Neut:
## contrast estimate SE df t.ratio p.value
## 0 - 1 1.03 2.6 242 0.395 0.6932
##
## Condition = NoGo, Emotion = Neut:
## contrast estimate SE df t.ratio p.value
## 0 - 1 5.46 2.6 242 2.099 0.0369
##
## Results are averaged over the levels of: calculator_gender_cve
## Degrees-of-freedom method: kenward-roger
pairs(emmeans_resulttalkergroupCondEmo, adjust = "none", simple = "each")
## $emmeans
## $`simple contrasts for talkergroup_final`
## Condition = Go, Emotion = Neg:
## contrast estimate SE df t.ratio p.value
## 0 - 1 2.57 2.6 242 0.990 0.3234
##
## Condition = NoGo, Emotion = Neg:
## contrast estimate SE df t.ratio p.value
## 0 - 1 2.87 2.6 242 1.102 0.2715
##
## Condition = Go, Emotion = Neut:
## contrast estimate SE df t.ratio p.value
## 0 - 1 1.03 2.6 242 0.395 0.6932
##
## Condition = NoGo, Emotion = Neut:
## contrast estimate SE df t.ratio p.value
## 0 - 1 5.46 2.6 242 2.099 0.0369
##
## Results are averaged over the levels of: calculator_gender_cve
## Degrees-of-freedom method: kenward-roger
##
## $`simple contrasts for Condition`
## talkergroup_final = 0, Emotion = Neg:
## contrast estimate SE df t.ratio p.value
## Go - NoGo 16.5 2.13 231 7.753 <.0001
##
## talkergroup_final = 1, Emotion = Neg:
## contrast estimate SE df t.ratio p.value
## Go - NoGo 16.8 2.27 231 7.406 <.0001
##
## talkergroup_final = 0, Emotion = Neut:
## contrast estimate SE df t.ratio p.value
## Go - NoGo 14.4 2.13 231 6.794 <.0001
##
## talkergroup_final = 1, Emotion = Neut:
## contrast estimate SE df t.ratio p.value
## Go - NoGo 18.9 2.27 231 8.334 <.0001
##
## Results are averaged over the levels of: calculator_gender_cve
## Degrees-of-freedom method: kenward-roger
##
## $`simple contrasts for Emotion`
## talkergroup_final = 0, Condition = Go:
## contrast estimate SE df t.ratio p.value
## Neg - Neut 2.03636 2.13 231 0.958 0.3392
##
## talkergroup_final = 1, Condition = Go:
## contrast estimate SE df t.ratio p.value
## Neg - Neut 0.48940 2.27 231 0.216 0.8291
##
## talkergroup_final = 0, Condition = NoGo:
## contrast estimate SE df t.ratio p.value
## Neg - Neut -0.00298 2.13 231 -0.001 0.9989
##
## talkergroup_final = 1, Condition = NoGo:
## contrast estimate SE df t.ratio p.value
## Neg - Neut 2.59005 2.27 231 1.143 0.2541
##
## Results are averaged over the levels of: calculator_gender_cve
## Degrees-of-freedom method: kenward-roger
##
##
## $contrasts
## $`simple contrasts for contrast`
## Condition = Go, Emotion = Neg:
## contrast estimate SE df z.ratio p.value
## (nothing) nonEst NA NA NA NA
##
## Condition = NoGo, Emotion = Neg:
## contrast estimate SE df z.ratio p.value
## (nothing) nonEst NA NA NA NA
##
## Condition = Go, Emotion = Neut:
## contrast estimate SE df z.ratio p.value
## (nothing) nonEst NA NA NA NA
##
## Condition = NoGo, Emotion = Neut:
## contrast estimate SE df z.ratio p.value
## (nothing) nonEst NA NA NA NA
##
## Results are averaged over the levels of: calculator_gender_cve
## Degrees-of-freedom method: kenward-roger
##
## $`simple contrasts for Condition`
## contrast = 0 - 1, Emotion = Neg:
## contrast1 estimate SE df t.ratio p.value
## Go - NoGo -0.293 3.11 231 -0.094 0.9250
##
## contrast = 0 - 1, Emotion = Neut:
## contrast1 estimate SE df t.ratio p.value
## Go - NoGo -4.433 3.11 231 -1.427 0.1550
##
## Results are averaged over the levels of: calculator_gender_cve
## Degrees-of-freedom method: kenward-roger
##
## $`simple contrasts for Emotion`
## contrast = 0 - 1, Condition = Go:
## contrast1 estimate SE df t.ratio p.value
## Neg - Neut 1.55 3.11 231 0.498 0.6190
##
## contrast = 0 - 1, Condition = NoGo:
## contrast1 estimate SE df t.ratio p.value
## Neg - Neut -2.59 3.11 231 -0.835 0.4048
##
## Results are averaged over the levels of: calculator_gender_cve
## Degrees-of-freedom method: kenward-roger
# PREMATURE RESPONSES
model1 <- lmer(premature_responses ~ talkergroup_final*Emotion*Condition +
calculator_gender_cve + calculator_age_cve + (1|Subject), data = ZOO_FCz_Pz, REML = TRUE)
anova(model1)
## Type III Analysis of Variance Table with Satterthwaite's method
## Sum Sq Mean Sq NumDF DenDF F value
## talkergroup_final 93.162 93.162 1 74.107 4.2783
## Emotion 69.043 69.043 1 227.126 3.1707
## Condition 151.067 151.067 1 227.126 6.9375
## calculator_gender_cve 2.866 2.866 1 74.028 0.1316
## calculator_age_cve 236.199 236.199 1 73.909 10.8471
## talkergroup_final:Emotion 74.558 74.558 1 227.378 3.4239
## talkergroup_final:Condition 101.711 101.711 1 227.378 4.6709
## Emotion:Condition 69.597 69.597 1 227.126 3.1962
## talkergroup_final:Emotion:Condition 52.435 52.435 1 227.378 2.4080
## Pr(>F)
## talkergroup_final 0.042091 *
## Emotion 0.076306 .
## Condition 0.009021 **
## calculator_gender_cve 0.717773
## calculator_age_cve 0.001520 **
## talkergroup_final:Emotion 0.065555 .
## talkergroup_final:Condition 0.031722 *
## Emotion:Condition 0.075145 .
## talkergroup_final:Emotion:Condition 0.122108
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
plot_model(model1, type="pred", terms = c("Emotion" , "Condition", "talkergroup_final"))
emmeans_result <- emmeans(model1, pairwise ~ talkergroup_final | Condition) # Tukey is default
## NOTE: Results may be misleading due to involvement in interactions
pairs(emmeans_result, adjust= "none", simple = "each") # adjust = "bonferroni"
## $emmeans
## $`simple contrasts for talkergroup_final`
## Condition = Go:
## contrast estimate SE df t.ratio p.value
## 0 - 1 -0.532 0.969 142 -0.549 0.5840
##
## Condition = NoGo:
## contrast estimate SE df t.ratio p.value
## 0 - 1 -2.828 0.972 143 -2.910 0.0042
##
## Results are averaged over the levels of: Emotion, calculator_gender_cve
## Degrees-of-freedom method: kenward-roger
##
## $`simple contrasts for Condition`
## talkergroup_final = 0:
## contrast estimate SE df t.ratio p.value
## Go - NoGo -1.90 0.720 227 -2.634 0.0090
##
## talkergroup_final = 1:
## contrast estimate SE df t.ratio p.value
## Go - NoGo -4.19 0.781 227 -5.368 <.0001
##
## Results are averaged over the levels of: Emotion, calculator_gender_cve
## Degrees-of-freedom method: kenward-roger
##
##
## $contrasts
## $`simple contrasts for contrast`
## Condition = Go:
## contrast estimate SE df z.ratio p.value
## (nothing) nonEst NA NA NA NA
##
## Condition = NoGo:
## contrast estimate SE df z.ratio p.value
## (nothing) nonEst NA NA NA NA
##
## Results are averaged over the levels of: Emotion, calculator_gender_cve
## Degrees-of-freedom method: kenward-roger
##
## $`simple contrasts for Condition`
## contrast = 0 - 1:
## contrast1 estimate SE df t.ratio p.value
## Go - NoGo 2.3 1.06 227 2.161 0.0317
##
## Results are averaged over the levels of: Emotion, calculator_gender_cve
## Degrees-of-freedom method: kenward-roger
emmeans_resultCondition <- emmeans(model1, pairwise ~ Condition)
## NOTE: Results may be misleading due to involvement in interactions
emmeans_resultCondition
## $emmeans
## Condition emmean SE df lower.CL upper.CL
## Go 1.54 0.487 141 0.581 2.51
## NoGo 4.59 0.488 142 3.623 5.55
##
## Results are averaged over the levels of: talkergroup_final, Emotion, calculator_gender_cve
## Degrees-of-freedom method: kenward-roger
## Confidence level used: 0.95
##
## $contrasts
## contrast estimate SE df t.ratio p.value
## Go - NoGo -3.04 0.531 227 -5.732 <.0001
##
## Results are averaged over the levels of: talkergroup_final, Emotion, calculator_gender_cve
## Degrees-of-freedom method: kenward-roger
emmeans_resulttalkergroupEmotion <- emmeans(model1, pairwise ~ talkergroup_final|Emotion)
## NOTE: Results may be misleading due to involvement in interactions
emmeans_resulttalkergroupEmotion
## $emmeans
## Emotion = Neg:
## talkergroup_final emmean SE df lower.CL upper.CL
## 0 2.87 0.659 142 1.564 4.17
## 1 3.56 0.714 141 2.153 4.98
##
## Emotion = Neut:
## talkergroup_final emmean SE df lower.CL upper.CL
## 0 1.58 0.659 142 0.282 2.89
## 1 4.25 0.717 143 2.830 5.66
##
## Results are averaged over the levels of: Condition, calculator_gender_cve
## Degrees-of-freedom method: kenward-roger
## Confidence level used: 0.95
##
## $contrasts
## Emotion = Neg:
## contrast estimate SE df t.ratio p.value
## 0 - 1 -0.697 0.969 142 -0.719 0.4733
##
## Emotion = Neut:
## contrast estimate SE df t.ratio p.value
## 0 - 1 -2.662 0.972 143 -2.740 0.0069
##
## Results are averaged over the levels of: Condition, calculator_gender_cve
## Degrees-of-freedom method: kenward-roger
pairs(emmeans_resulttalkergroupEmotion, adjust = "none", simple = "each")
## $emmeans
## $`simple contrasts for talkergroup_final`
## Emotion = Neg:
## contrast estimate SE df t.ratio p.value
## 0 - 1 -0.697 0.969 142 -0.719 0.4733
##
## Emotion = Neut:
## contrast estimate SE df t.ratio p.value
## 0 - 1 -2.662 0.972 143 -2.740 0.0069
##
## Results are averaged over the levels of: Condition, calculator_gender_cve
## Degrees-of-freedom method: kenward-roger
##
## $`simple contrasts for Emotion`
## talkergroup_final = 0:
## contrast estimate SE df t.ratio p.value
## Neg - Neut 1.282 0.720 227 1.781 0.0763
##
## talkergroup_final = 1:
## contrast estimate SE df t.ratio p.value
## Neg - Neut -0.683 0.781 227 -0.875 0.3825
##
## Results are averaged over the levels of: Condition, calculator_gender_cve
## Degrees-of-freedom method: kenward-roger
##
##
## $contrasts
## $`simple contrasts for contrast`
## Emotion = Neg:
## contrast estimate SE df z.ratio p.value
## (nothing) nonEst NA NA NA NA
##
## Emotion = Neut:
## contrast estimate SE df z.ratio p.value
## (nothing) nonEst NA NA NA NA
##
## Results are averaged over the levels of: Condition, calculator_gender_cve
## Degrees-of-freedom method: kenward-roger
##
## $`simple contrasts for Emotion`
## contrast = 0 - 1:
## contrast1 estimate SE df t.ratio p.value
## Neg - Neut 1.97 1.06 227 1.850 0.0656
##
## Results are averaged over the levels of: Condition, calculator_gender_cve
## Degrees-of-freedom method: kenward-roger
emmeans_resulttalkergroup <- emmeans(model1, pairwise ~ talkergroup_final)
## NOTE: Results may be misleading due to involvement in interactions
emmeans_resulttalkergroup
## $emmeans
## talkergroup_final emmean SE df lower.CL upper.CL
## 0 2.23 0.552 73.8 1.13 3.33
## 1 3.91 0.600 74.2 2.71 5.10
##
## Results are averaged over the levels of: Emotion, Condition, calculator_gender_cve
## Degrees-of-freedom method: kenward-roger
## Confidence level used: 0.95
##
## $contrasts
## contrast estimate SE df t.ratio p.value
## 0 - 1 -1.68 0.812 74 -2.068 0.0421
##
## Results are averaged over the levels of: Emotion, Condition, calculator_gender_cve
## Degrees-of-freedom method: kenward-roger
emmeans_resulttalkergroupCond <- emmeans(model1, pairwise ~ talkergroup_final|Condition)
## NOTE: Results may be misleading due to involvement in interactions
emmeans_resulttalkergroupCond
## $emmeans
## Condition = Go:
## talkergroup_final emmean SE df lower.CL upper.CL
## 0 1.28 0.659 142 -0.0251 2.58
## 1 1.81 0.714 141 0.3982 3.22
##
## Condition = NoGo:
## talkergroup_final emmean SE df lower.CL upper.CL
## 0 3.17 0.659 142 1.8714 4.48
## 1 6.00 0.717 143 4.5841 7.42
##
## Results are averaged over the levels of: Emotion, calculator_gender_cve
## Degrees-of-freedom method: kenward-roger
## Confidence level used: 0.95
##
## $contrasts
## Condition = Go:
## contrast estimate SE df t.ratio p.value
## 0 - 1 -0.532 0.969 142 -0.549 0.5840
##
## Condition = NoGo:
## contrast estimate SE df t.ratio p.value
## 0 - 1 -2.828 0.972 143 -2.910 0.0042
##
## Results are averaged over the levels of: Emotion, calculator_gender_cve
## Degrees-of-freedom method: kenward-roger
pairs(emmeans_resulttalkergroupCond, adjust = "none", simple = "each")
## $emmeans
## $`simple contrasts for talkergroup_final`
## Condition = Go:
## contrast estimate SE df t.ratio p.value
## 0 - 1 -0.532 0.969 142 -0.549 0.5840
##
## Condition = NoGo:
## contrast estimate SE df t.ratio p.value
## 0 - 1 -2.828 0.972 143 -2.910 0.0042
##
## Results are averaged over the levels of: Emotion, calculator_gender_cve
## Degrees-of-freedom method: kenward-roger
##
## $`simple contrasts for Condition`
## talkergroup_final = 0:
## contrast estimate SE df t.ratio p.value
## Go - NoGo -1.90 0.720 227 -2.634 0.0090
##
## talkergroup_final = 1:
## contrast estimate SE df t.ratio p.value
## Go - NoGo -4.19 0.781 227 -5.368 <.0001
##
## Results are averaged over the levels of: Emotion, calculator_gender_cve
## Degrees-of-freedom method: kenward-roger
##
##
## $contrasts
## $`simple contrasts for contrast`
## Condition = Go:
## contrast estimate SE df z.ratio p.value
## (nothing) nonEst NA NA NA NA
##
## Condition = NoGo:
## contrast estimate SE df z.ratio p.value
## (nothing) nonEst NA NA NA NA
##
## Results are averaged over the levels of: Emotion, calculator_gender_cve
## Degrees-of-freedom method: kenward-roger
##
## $`simple contrasts for Condition`
## contrast = 0 - 1:
## contrast1 estimate SE df t.ratio p.value
## Go - NoGo 2.3 1.06 227 2.161 0.0317
##
## Results are averaged over the levels of: Emotion, calculator_gender_cve
## Degrees-of-freedom method: kenward-roger
emmeans_resulttalkergroupCondEmo <- emmeans(model1, pairwise ~ talkergroup_final|Condition|Emotion)
emmeans_resulttalkergroupCondEmo
## $emmeans
## Condition = Go, Emotion = Neg:
## talkergroup_final emmean SE df lower.CL upper.CL
## 0 1.28 0.833 250 -0.365 2.92
## 1 1.65 0.901 249 -0.127 3.42
##
## Condition = NoGo, Emotion = Neg:
## talkergroup_final emmean SE df lower.CL upper.CL
## 0 4.46 0.833 250 2.819 6.10
## 1 5.48 0.901 249 3.705 7.25
##
## Condition = Go, Emotion = Neut:
## talkergroup_final emmean SE df lower.CL upper.CL
## 0 1.28 0.833 250 -0.360 2.92
## 1 1.97 0.901 249 0.196 3.75
##
## Condition = NoGo, Emotion = Neut:
## talkergroup_final emmean SE df lower.CL upper.CL
## 0 1.89 0.833 250 0.249 3.53
## 1 6.52 0.912 252 4.728 8.32
##
## Results are averaged over the levels of: calculator_gender_cve
## Degrees-of-freedom method: kenward-roger
## Confidence level used: 0.95
##
## $contrasts
## Condition = Go, Emotion = Neg:
## contrast estimate SE df t.ratio p.value
## 0 - 1 -0.373 1.23 250 -0.305 0.7609
##
## Condition = NoGo, Emotion = Neg:
## contrast estimate SE df t.ratio p.value
## 0 - 1 -1.021 1.23 250 -0.833 0.4056
##
## Condition = Go, Emotion = Neut:
## contrast estimate SE df t.ratio p.value
## 0 - 1 -0.690 1.23 250 -0.564 0.5736
##
## Condition = NoGo, Emotion = Neut:
## contrast estimate SE df t.ratio p.value
## 0 - 1 -4.635 1.23 252 -3.758 0.0002
##
## Results are averaged over the levels of: calculator_gender_cve
## Degrees-of-freedom method: kenward-roger
pairs(emmeans_resulttalkergroupCondEmo, adjust = "none", simple = "each")
## $emmeans
## $`simple contrasts for talkergroup_final`
## Condition = Go, Emotion = Neg:
## contrast estimate SE df t.ratio p.value
## 0 - 1 -0.373 1.23 250 -0.305 0.7609
##
## Condition = NoGo, Emotion = Neg:
## contrast estimate SE df t.ratio p.value
## 0 - 1 -1.021 1.23 250 -0.833 0.4056
##
## Condition = Go, Emotion = Neut:
## contrast estimate SE df t.ratio p.value
## 0 - 1 -0.690 1.23 250 -0.564 0.5736
##
## Condition = NoGo, Emotion = Neut:
## contrast estimate SE df t.ratio p.value
## 0 - 1 -4.635 1.23 252 -3.758 0.0002
##
## Results are averaged over the levels of: calculator_gender_cve
## Degrees-of-freedom method: kenward-roger
##
## $`simple contrasts for Condition`
## talkergroup_final = 0, Emotion = Neg:
## contrast estimate SE df t.ratio p.value
## Go - NoGo -3.184 1.02 227 -3.127 0.0020
##
## talkergroup_final = 1, Emotion = Neg:
## contrast estimate SE df t.ratio p.value
## Go - NoGo -3.831 1.10 227 -3.483 0.0006
##
## talkergroup_final = 0, Emotion = Neut:
## contrast estimate SE df t.ratio p.value
## Go - NoGo -0.609 1.02 227 -0.598 0.5502
##
## talkergroup_final = 1, Emotion = Neut:
## contrast estimate SE df t.ratio p.value
## Go - NoGo -4.553 1.11 228 -4.106 0.0001
##
## Results are averaged over the levels of: calculator_gender_cve
## Degrees-of-freedom method: kenward-roger
##
## $`simple contrasts for Emotion`
## talkergroup_final = 0, Condition = Go:
## contrast estimate SE df t.ratio p.value
## Neg - Neut -0.00513 1.02 227 -0.005 0.9960
##
## talkergroup_final = 1, Condition = Go:
## contrast estimate SE df t.ratio p.value
## Neg - Neut -0.32234 1.10 227 -0.293 0.7697
##
## talkergroup_final = 0, Condition = NoGo:
## contrast estimate SE df t.ratio p.value
## Neg - Neut 2.56942 1.02 227 2.523 0.0123
##
## talkergroup_final = 1, Condition = NoGo:
## contrast estimate SE df t.ratio p.value
## Neg - Neut -1.04453 1.11 228 -0.942 0.3473
##
## Results are averaged over the levels of: calculator_gender_cve
## Degrees-of-freedom method: kenward-roger
##
##
## $contrasts
## $`simple contrasts for contrast`
## Condition = Go, Emotion = Neg:
## contrast estimate SE df z.ratio p.value
## (nothing) nonEst NA NA NA NA
##
## Condition = NoGo, Emotion = Neg:
## contrast estimate SE df z.ratio p.value
## (nothing) nonEst NA NA NA NA
##
## Condition = Go, Emotion = Neut:
## contrast estimate SE df z.ratio p.value
## (nothing) nonEst NA NA NA NA
##
## Condition = NoGo, Emotion = Neut:
## contrast estimate SE df z.ratio p.value
## (nothing) nonEst NA NA NA NA
##
## Results are averaged over the levels of: calculator_gender_cve
## Degrees-of-freedom method: kenward-roger
##
## $`simple contrasts for Condition`
## contrast = 0 - 1, Emotion = Neg:
## contrast1 estimate SE df t.ratio p.value
## Go - NoGo 0.647 1.50 227 0.432 0.6662
##
## contrast = 0 - 1, Emotion = Neut:
## contrast1 estimate SE df t.ratio p.value
## Go - NoGo 3.944 1.51 228 2.620 0.0094
##
## Results are averaged over the levels of: calculator_gender_cve
## Degrees-of-freedom method: kenward-roger
##
## $`simple contrasts for Emotion`
## contrast = 0 - 1, Condition = Go:
## contrast1 estimate SE df t.ratio p.value
## Neg - Neut 0.317 1.50 227 0.212 0.8326
##
## contrast = 0 - 1, Condition = NoGo:
## contrast1 estimate SE df t.ratio p.value
## Neg - Neut 3.614 1.51 228 2.400 0.0172
##
## Results are averaged over the levels of: calculator_gender_cve
## Degrees-of-freedom method: kenward-roger
ZOO_FCz_Pz_GO <- subset(ZOO_FCz_Pz, Condition == 'Go')
ZOO_FCz_Pz_NOGO <- subset(ZOO_FCz_Pz, Condition == 'NoGo')
model1 <- lmer(RT_proper ~ talkergroup_final*Emotion +
calculator_gender_cve + calculator_age_cve + (1|Subject), data = ZOO_FCz_Pz_GO, REML = TRUE)
anova(model1)
## Type III Analysis of Variance Table with Satterthwaite's method
## Sum Sq Mean Sq NumDF DenDF F value Pr(>F)
## talkergroup_final 8810 8810 1 74 2.8719 0.09434 .
## Emotion 5689 5689 1 76 1.8545 0.17728
## calculator_gender_cve 5399 5399 1 74 1.7601 0.18869
## calculator_age_cve 161404 161404 1 74 52.6144 3.3e-10 ***
## talkergroup_final:Emotion 160 160 1 76 0.0521 0.81998
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
plot_model(model1, type="pred", terms = c("Emotion" , "talkergroup_final"))
emmeans_result <- emmeans(model1, pairwise ~ talkergroup_final | Emotion) # Tukey is default
pairs(emmeans_result, adjust= "none", simple = "each") # adjust = "bonferroni"
## $emmeans
## $`simple contrasts for talkergroup_final`
## Emotion = Neg:
## contrast estimate SE df t.ratio p.value
## 0 - 1 -37.1 22.5 100 -1.647 0.1026
##
## Emotion = Neut:
## contrast estimate SE df t.ratio p.value
## 0 - 1 -33.1 22.5 100 -1.467 0.1455
##
## Results are averaged over the levels of: calculator_gender_cve
## Degrees-of-freedom method: kenward-roger
##
## $`simple contrasts for Emotion`
## talkergroup_final = 0:
## contrast estimate SE df t.ratio p.value
## Neg - Neut 16.5 12.1 76 1.362 0.1773
##
## talkergroup_final = 1:
## contrast estimate SE df t.ratio p.value
## Neg - Neut 20.5 13.1 76 1.572 0.1201
##
## Results are averaged over the levels of: calculator_gender_cve
## Degrees-of-freedom method: kenward-roger
##
##
## $contrasts
## $`simple contrasts for contrast`
## Emotion = Neg:
## contrast estimate SE df z.ratio p.value
## (nothing) nonEst NA NA NA NA
##
## Emotion = Neut:
## contrast estimate SE df z.ratio p.value
## (nothing) nonEst NA NA NA NA
##
## Results are averaged over the levels of: calculator_gender_cve
## Degrees-of-freedom method: kenward-roger
##
## $`simple contrasts for Emotion`
## contrast = 0 - 1:
## contrast1 estimate SE df t.ratio p.value
## Neg - Neut -4.06 17.8 76 -0.228 0.8200
##
## Results are averaged over the levels of: calculator_gender_cve
## Degrees-of-freedom method: kenward-roger
model1 <- lmer(RT_proper ~ talkergroup_final*Emotion +
calculator_gender_cve + calculator_age_cve + (1|Subject), data = ZOO_FCz_Pz_NOGO, REML = TRUE)
anova(model1)
## Type III Analysis of Variance Table with Satterthwaite's method
## Sum Sq Mean Sq NumDF DenDF F value Pr(>F)
## talkergroup_final 115131 115131 1 73.832 4.8966 0.0300 *
## Emotion 23068 23068 1 75.014 0.9811 0.3251
## calculator_gender_cve 34253 34253 1 73.675 1.4568 0.2313
## calculator_age_cve 910160 910160 1 73.436 38.7098 2.733e-08 ***
## talkergroup_final:Emotion 1892 1892 1 75.513 0.0805 0.7774
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
plot_model(model1, type="pred", terms = c("Emotion" , "talkergroup_final"))
emmeans_result <- emmeans(model1, pairwise ~ talkergroup_final | Emotion) # Tukey is default
pairs(emmeans_result, adjust= "none", simple = "each") # adjust = "bonferroni"
## $emmeans
## $`simple contrasts for talkergroup_final`
## Emotion = Neg:
## contrast estimate SE df t.ratio p.value
## 0 - 1 -72.6 43.5 131 -1.667 0.0978
##
## Emotion = Neut:
## contrast estimate SE df t.ratio p.value
## 0 - 1 -86.6 43.8 132 -1.977 0.0501
##
## Results are averaged over the levels of: calculator_gender_cve
## Degrees-of-freedom method: kenward-roger
##
## $`simple contrasts for Emotion`
## talkergroup_final = 0:
## contrast estimate SE df t.ratio p.value
## Neg - Neut -33.1 33.5 75.1 -0.991 0.3251
##
## talkergroup_final = 1:
## contrast estimate SE df t.ratio p.value
## Neg - Neut -47.2 36.5 76.0 -1.293 0.2000
##
## Results are averaged over the levels of: calculator_gender_cve
## Degrees-of-freedom method: kenward-roger
##
##
## $contrasts
## $`simple contrasts for contrast`
## Emotion = Neg:
## contrast estimate SE df z.ratio p.value
## (nothing) nonEst NA NA NA NA
##
## Emotion = Neut:
## contrast estimate SE df z.ratio p.value
## (nothing) nonEst NA NA NA NA
##
## Results are averaged over the levels of: calculator_gender_cve
## Degrees-of-freedom method: kenward-roger
##
## $`simple contrasts for Emotion`
## contrast = 0 - 1:
## contrast1 estimate SE df t.ratio p.value
## Neg - Neut 14 49.5 75.6 0.284 0.7775
##
## Results are averaged over the levels of: calculator_gender_cve
## Degrees-of-freedom method: kenward-roger
model1 <- aov(RT_proper ~ talkergroup_final*Emotion + calculator_age_cve +calculator_gender_cve + Error(Subject/(Emotion)), data = ZOO_FCz_Pz_GO)
summary(model1)
##
## Error: Subject
## Df Sum Sq Mean Sq F value Pr(>F)
## talkergroup_final 1 30478 30478 1.836 0.179
## calculator_age_cve 1 877460 877460 52.872 3.06e-10 ***
## calculator_gender_cve 1 29211 29211 1.760 0.189
## Residuals 74 1228107 16596
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Error: Subject:Emotion
## Df Sum Sq Mean Sq F value Pr(>F)
## Emotion 1 13110 13110 4.274 0.0421 *
## talkergroup_final:Emotion 1 160 160 0.052 0.8200
## Residuals 76 233143 3068
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# LATERALITY - LATERALITY TALKERGROUP INTERACTION
model1 <- lmer(MeanAmp_P3 ~ talkergroup_final*Emotion*Condition*Laterality + calculator_gender_cve + calculator_age_cve +
(1|Subject), data = ZOO_good, REML = TRUE)
anova(model1)
## Type III Analysis of Variance Table with Satterthwaite's method
## Sum Sq Mean Sq NumDF DenDF
## talkergroup_final 3.69 3.69 1 75
## Emotion 9.92 9.92 1 847
## Condition 75.97 75.97 1 847
## Laterality 1932.65 966.33 2 847
## calculator_gender_cve 3.36 3.36 1 75
## calculator_age_cve 1.57 1.57 1 75
## talkergroup_final:Emotion 11.64 11.64 1 847
## talkergroup_final:Condition 2.34 2.34 1 847
## Emotion:Condition 1.42 1.42 1 847
## talkergroup_final:Laterality 103.33 51.66 2 847
## Emotion:Laterality 10.48 5.24 2 847
## Condition:Laterality 71.01 35.50 2 847
## talkergroup_final:Emotion:Condition 29.53 29.53 1 847
## talkergroup_final:Emotion:Laterality 1.96 0.98 2 847
## talkergroup_final:Condition:Laterality 56.14 28.07 2 847
## Emotion:Condition:Laterality 0.15 0.08 2 847
## talkergroup_final:Emotion:Condition:Laterality 4.78 2.39 2 847
## F value Pr(>F)
## talkergroup_final 0.2325 0.63107
## Emotion 0.6258 0.42913
## Condition 4.7923 0.02886 *
## Laterality 60.9583 < 2e-16 ***
## calculator_gender_cve 0.2122 0.64637
## calculator_age_cve 0.0988 0.75412
## talkergroup_final:Emotion 0.7346 0.39164
## talkergroup_final:Condition 0.1475 0.70101
## Emotion:Condition 0.0894 0.76504
## talkergroup_final:Laterality 3.2591 0.03890 *
## Emotion:Laterality 0.3305 0.71864
## Condition:Laterality 2.2396 0.10713
## talkergroup_final:Emotion:Condition 1.8626 0.17269
## talkergroup_final:Emotion:Laterality 0.0619 0.93994
## talkergroup_final:Condition:Laterality 1.7709 0.17082
## Emotion:Condition:Laterality 0.0047 0.99527
## talkergroup_final:Emotion:Condition:Laterality 0.1509 0.85998
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
plot_model(model1, type="pred", terms = c("Laterality", "talkergroup_final"))
plot_model(model1, type="pred", terms = c("Condition"))
plot_model(model1, type="pred", terms = c("Laterality"))
# plot_model(model1, type="pred", terms = c("Laterality", "Condition", "talkergroup_final"))
# MIDDLE - CONDITION ONLY
model1 <- lmer(MeanAmp_P3 ~ talkergroup_final*Emotion*Condition + calculator_gender_cve + calculator_age_cve +
(1|Subject), data = ZOO_FCz_Pz, REML = TRUE)
anova(model1)
## Type III Analysis of Variance Table with Satterthwaite's method
## Sum Sq Mean Sq NumDF DenDF F value
## talkergroup_final 24.019 24.019 1 75 2.0383
## Emotion 1.483 1.483 1 231 0.1258
## Condition 131.826 131.826 1 231 11.1872
## calculator_gender_cve 0.183 0.183 1 75 0.0155
## calculator_age_cve 2.443 2.443 1 75 0.2073
## talkergroup_final:Emotion 4.736 4.736 1 231 0.4019
## talkergroup_final:Condition 0.187 0.187 1 231 0.0158
## Emotion:Condition 0.155 0.155 1 231 0.0131
## talkergroup_final:Emotion:Condition 1.912 1.912 1 231 0.1623
## Pr(>F)
## talkergroup_final 0.157531
## Emotion 0.723101
## Condition 0.000961 ***
## calculator_gender_cve 0.901109
## calculator_age_cve 0.650169
## talkergroup_final:Emotion 0.526745
## talkergroup_final:Condition 0.899958
## Emotion:Condition 0.908861
## talkergroup_final:Emotion:Condition 0.687446
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
plot_model(model1, type="pred", terms = c("Emotion" , "Condition", "talkergroup_final"))
# Calculate marginal means for NONEXISTENT the three-way interaction
means <- as.data.frame(emmeans(model1, specs = ~ talkergroup_final:Emotion:Condition))
# Rename the levels of the "talkergroup_final" factor
means$talkergroup_final <- factor(means$talkergroup_final, levels = c(0, 1), labels = c("CWNS", "CWS"))
means$Emotion <- factor(means$Emotion, levels = c("Neg", "Neut"), labels = c("Affective", "Neutral"))
bar_plot <- ggplot(means, aes(x = Emotion, y = emmean, fill = Condition)) +
geom_bar(stat = "identity", position = "dodge") +
geom_errorbar(aes(ymin = emmean - SE, ymax = emmean + SE), width = 0.2, position = position_dodge(0.9)) +
labs(x = "Emotion", y = "Mean P3 in μV") +
facet_grid(. ~ talkergroup_final) +
theme_minimal() +
theme(
axis.text = element_text(size = 14, color = "black"),
axis.title = element_text(size = 14),
legend.title =element_blank(),
legend.text = element_text(size = 14),
plot.title = element_text(hjust = 0.5, size = 14, face = "bold", vjust = 2),
strip.text = element_text(size = 14, face = "bold")) +
scale_fill_manual(values = c("royalblue2", "orangered", "royalblue2", "orangered", "royalblue2", "orangered", "royalblue2", "orangered"))
bar_plot <- bar_plot + coord_cartesian(ylim = c(4, 12))
print(bar_plot)
bar_plot <- ggplot(means, aes(x = Condition, y = emmean, fill = Emotion)) +
geom_bar(stat = "identity", position = "dodge") +
geom_errorbar(aes(ymin = emmean - SE, ymax = emmean + SE), width = 0.2, position = position_dodge(0.9)) +
labs(x = "Condition", y = "Mean P3 in μV") +
facet_grid(. ~ talkergroup_final) +
theme_minimal() +
theme(
axis.text = element_text(size = 14, color = "black"),
axis.title = element_text(size = 14),
legend.title =element_blank(),
legend.text = element_text(size = 14),
plot.title = element_text(hjust = 0.5, size = 14, face = "bold", vjust = 2),
strip.text = element_text(size = 14, face = "bold")) +
scale_fill_manual(values = c("springgreen3", "royalblue2", "springgreen3", "royalblue2", "springgreen3", "royalblue2", "springgreen3", "royalblue2"))
bar_plot <- bar_plot + coord_cartesian(ylim = c(4, 12))
print(bar_plot)
# GO CONDITION ONLY!
ZOO_FCz_Pz_GO <- subset(ZOO_FCz_Pz, Condition == "Go")
model1 <- aov(MeanAmp_P3 ~ talkergroup_final*Emotion + calculator_gender_cve + calculator_age_cve, data = ZOO_FCz_Pz_GO)
summary(model1)
## Df Sum Sq Mean Sq F value Pr(>F)
## talkergroup_final 1 53.8 53.80 2.749 0.0994 .
## Emotion 1 15.4 15.40 0.787 0.3764
## calculator_gender_cve 1 7.1 7.10 0.363 0.5478
## calculator_age_cve 1 3.1 3.10 0.158 0.6914
## talkergroup_final:Emotion 1 6.3 6.33 0.324 0.5703
## Residuals 152 2974.2 19.57
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
model1 <- lmer(MeanAmp_P3 ~ talkergroup_final*Emotion + calculator_age_cve + calculator_gender_cve +
(1|Subject), data = ZOO_FCz_Pz_GO, REML = TRUE)
anova(model1)
## Type III Analysis of Variance Table with Satterthwaite's method
## Sum Sq Mean Sq NumDF DenDF F value Pr(>F)
## talkergroup_final 9.2019 9.2019 1 75 1.6603 0.2015
## Emotion 1.2979 1.2979 1 77 0.2342 0.6298
## calculator_age_cve 0.5051 0.5051 1 75 0.0911 0.7636
## calculator_gender_cve 1.1453 1.1453 1 75 0.2067 0.6507
## talkergroup_final:Emotion 6.3331 6.3331 1 77 1.1427 0.2884
plot_model(model1, type="pred", terms = c("Emotion"))
plot_model(model1, type="pred", terms = c("Emotion", "talkergroup_final"))
# Calculate marginal means for the three-way interaction
means <- as.data.frame(emmeans(model1, specs = ~ talkergroup_final:Emotion))
# filtered_means <- means[means$Condition == "Go", ] # keep all columns
means$talkergroup_final <- factor(means$talkergroup_final, levels = c(0, 1), labels = c("CWNS", "CWS"))
means$Emotion <- factor(means$Emotion, levels = c("Neg", "Neut"), labels = c("Affective", "Neutral"))
bar_plot <- ggplot(means, aes(x = Emotion, y = emmean)) +
geom_bar(stat = "identity", position = "dodge") +
geom_errorbar(aes(ymin = emmean - SE, ymax = emmean + SE), width = 0.2, position = position_dodge(0.9)) +
labs(x = "Emotion", y = "Mean P3 in μV") +
facet_grid(. ~ talkergroup_final) +
theme_minimal() +
theme(
axis.text = element_text(size = 14, color = "black"),
axis.title = element_text(size = 14),
legend.title =element_blank(),
legend.text = element_text(size = 14),
plot.title = element_text(hjust = 0.5, size = 14, face = "bold", vjust = 2),
strip.text = element_text(size = 14, face = "bold")) +
scale_fill_manual(values = c("springgreen3", "royalblue2", "springgreen3", "royalblue2"))
print(bar_plot)
collapsed_accuracy <-
ZOO_FCz_Pz %>%
group_by(Subject, talkergroup_final, Condition) %>%
summarise(
accuracy = mean(accuracy, na.rm = TRUE),
calculator_age_cve = mean(calculator_age_cve, na.rm = TRUE),
calculator_gender_cve = mean(calculator_gender_cve, na.rm = TRUE),
MeanAmp_N2P2 = mean(MeanAmp_N2P2, na.rm = TRUE),
MeanAmp_P3 = mean(MeanAmp_P3, na.rm = TRUE),
MeanAmp_P2 = mean(MeanAmp_P2, na.rm = TRUE),
Latency_N2 = mean(Latency_N2, na.rm = TRUE),
Latency_P3 = mean(Latency_P3, na.rm = TRUE),
Latency_P2 = mean(Latency_P2, na.rm = TRUE)
)
## `summarise()` has grouped output by 'Subject', 'talkergroup_final'. You can
## override using the `.groups` argument.
model1 <- lmer(accuracy ~ talkergroup_final*Condition + MeanAmp_N2P2 + MeanAmp_P3 +MeanAmp_P2 + Latency_N2 + Latency_P3 + Latency_P2 + calculator_age_cve+calculator_gender_cve + (1|Subject),
data = collapsed_accuracy)
anova(model1)
## Type III Analysis of Variance Table with Satterthwaite's method
## Sum Sq Mean Sq NumDF DenDF F value Pr(>F)
## talkergroup_final 241.4 241.4 1 71.036 2.9993 0.087639 .
## Condition 3442.1 3442.1 1 103.252 42.7630 2.407e-09 ***
## MeanAmp_N2P2 51.8 51.8 1 116.361 0.6433 0.424168
## MeanAmp_P3 278.3 278.3 1 112.543 3.4575 0.065577 .
## MeanAmp_P2 409.3 409.3 1 124.183 5.0853 0.025880 *
## Latency_N2 205.6 205.6 1 144.934 2.5548 0.112138
## Latency_P3 303.7 303.7 1 141.533 3.7736 0.054053 .
## Latency_P2 0.5 0.5 1 144.761 0.0056 0.940238
## calculator_age_cve 627.4 627.4 1 75.421 7.7945 0.006636 **
## calculator_gender_cve 63.3 63.3 1 70.003 0.7862 0.378285
## talkergroup_final:Condition 76.0 76.0 1 73.489 0.9445 0.334300
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
AIC(model1)
## [1] 1199.174
model2 <- aov(accuracy ~ talkergroup_final*Condition + MeanAmp_N2P2 + MeanAmp_P3 +MeanAmp_P2 + Latency_N2 + Latency_P3 + Latency_P2 + calculator_age_cve+calculator_gender_cve +
Error(Subject/Condition), data = collapsed_accuracy)
summary(model2)
##
## Error: Subject
## Df Sum Sq Mean Sq F value Pr(>F)
## talkergroup_final 1 331 330.6 2.776 0.1002
## MeanAmp_N2P2 1 9 8.9 0.075 0.7853
## MeanAmp_P3 1 739 738.7 6.202 0.0152 *
## MeanAmp_P2 1 18 18.1 0.152 0.6977
## Latency_N2 1 66 66.0 0.554 0.4591
## Latency_P3 1 222 222.2 1.865 0.1765
## Latency_P2 1 137 137.0 1.150 0.2873
## calculator_age_cve 1 631 631.3 5.300 0.0243 *
## calculator_gender_cve 1 107 107.2 0.900 0.3461
## Residuals 69 8219 119.1
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Error: Subject:Condition
## Df Sum Sq Mean Sq F value Pr(>F)
## Condition 1 10847 10847 141.607 <2e-16 ***
## MeanAmp_N2P2 1 57 57 0.738 0.3932
## MeanAmp_P3 1 27 27 0.350 0.5558
## MeanAmp_P2 1 485 485 6.336 0.0141 *
## Latency_N2 1 291 291 3.797 0.0553 .
## Latency_P3 1 502 502 6.558 0.0126 *
## Latency_P2 1 70 70 0.908 0.3439
## talkergroup_final:Condition 1 109 109 1.422 0.2370
## Residuals 71 5439 77
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# Check the residuals of your chosen model to ensure they are normally distributed and homoscedastic. If they are not, you may need to consider transformations of your dependent variable or a different type of model.
model1 <- lmer(accuracy ~ talkergroup_final*Condition*MeanAmp_P3 + calculator_age_cve+calculator_gender_cve + (1|Subject),
data = collapsed_accuracy)
anova(model1)
## Type III Analysis of Variance Table with Satterthwaite's method
## Sum Sq Mean Sq NumDF DenDF F value
## talkergroup_final 30.09 30.09 1 111.951 0.3516
## Condition 2337.48 2337.48 1 91.214 27.3105
## MeanAmp_P3 539.47 539.47 1 108.326 6.3030
## calculator_age_cve 469.80 469.80 1 73.479 5.4890
## calculator_gender_cve 80.19 80.19 1 73.491 0.9370
## talkergroup_final:Condition 41.41 41.41 1 97.598 0.4838
## talkergroup_final:MeanAmp_P3 122.86 122.86 1 121.551 1.4355
## Condition:MeanAmp_P3 369.94 369.94 1 94.038 4.3222
## talkergroup_final:Condition:MeanAmp_P3 59.91 59.91 1 102.836 0.7000
## Pr(>F)
## talkergroup_final 0.55442
## Condition 1.09e-06 ***
## MeanAmp_P3 0.01353 *
## calculator_age_cve 0.02185 *
## calculator_gender_cve 0.33623
## talkergroup_final:Condition 0.48835
## talkergroup_final:MeanAmp_P3 0.23320
## Condition:MeanAmp_P3 0.04034 *
## talkergroup_final:Condition:MeanAmp_P3 0.40473
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#MODERATOR ANALYSIS WITH ALL CORTICAL MEASURES:
# Select columns from df1
selected_df1 <- select(ZOO_FCz_Pz, Subject, talkergroup_final, accuracy, calculator_age_cve, Condition, Emotion, MeanAmp_N2P2, MeanAmp_N2, MeanAmp_P2, MeanAmp_P3, Latency_N2, Latency_P2, Latency_P3)
# Converting into numerical variable:
encoded_data1 <- model.matrix(~ Condition + 0, data = selected_df1)
encoded_data2 <- model.matrix(~ Emotion + 0, data = selected_df1)
# Combine the original dataframe with the encoded and scaled variables
merged_df1 <- cbind(selected_df1, encoded_data1, encoded_data2)
merged_df2 <- subset(merged_df1, select = -c(Subject, ConditionNoGo, EmotionNeut, Condition, Emotion))
# Scaling the variables
# Specify the columns you want to scale
columns_to_scale <- c("MeanAmp_N2P2", "MeanAmp_N2", "MeanAmp_P2","MeanAmp_P3", "Latency_N2","Latency_P2", "Latency_P3")
# Subset the data frame to include only the columns you want to scale
subset_df <- merged_df2[, columns_to_scale]
# Scale the selected columns
scaled_subset_df <- as.data.frame(scale(subset_df))
# subjects <- subset(merged_df1, select = c(Subject))
# Get the Unscaled columns + Subjects Column
merged_df1_small <- subset(merged_df1, select = c( Subject, talkergroup_final, accuracy, calculator_age_cve, ConditionGo, EmotionNeg))
# Combine the scaled subset with the original data frame
final_merged <- cbind(merged_df1_small, scaled_subset_df)
# Rename condition and emotion
final_merged <- final_merged %>%
rename(Condition = ConditionGo, Emotion = EmotionNeg)
model1 <- lmer(accuracy ~ talkergroup_final*Condition*Emotion + MeanAmp_N2P2 + MeanAmp_P3 +MeanAmp_P2 + Latency_N2 + Latency_P3 + Latency_P2 + calculator_age_cve + (1|Subject),
data = final_merged)
anova(model1)
## Type III Analysis of Variance Table with Satterthwaite's method
## Sum Sq Mean Sq NumDF DenDF F value
## talkergroup_final 378.7 378.7 1 248.567 3.9877
## Condition 4198.9 4198.9 1 249.518 44.2122
## Emotion 0.1 0.1 1 228.887 0.0008
## MeanAmp_N2P2 46.2 46.2 1 254.889 0.4861
## MeanAmp_P3 370.9 370.9 1 251.185 3.9052
## MeanAmp_P2 412.2 412.2 1 271.839 4.3402
## Latency_N2 101.9 101.9 1 298.685 1.0730
## Latency_P3 237.9 237.9 1 300.334 2.5047
## Latency_P2 3.0 3.0 1 299.501 0.0318
## calculator_age_cve 714.4 714.4 1 81.859 7.5220
## talkergroup_final:Condition 151.2 151.2 1 230.361 1.5922
## talkergroup_final:Emotion 35.2 35.2 1 230.058 0.3709
## Condition:Emotion 22.9 22.9 1 228.521 0.2416
## talkergroup_final:Condition:Emotion 41.3 41.3 1 232.415 0.4349
## Pr(>F)
## talkergroup_final 0.046925 *
## Condition 1.846e-10 ***
## Emotion 0.977713
## MeanAmp_N2P2 0.486306
## MeanAmp_P3 0.049231 *
## MeanAmp_P2 0.038157 *
## Latency_N2 0.301115
## Latency_P3 0.114561
## Latency_P2 0.858656
## calculator_age_cve 0.007485 **
## talkergroup_final:Condition 0.208295
## talkergroup_final:Emotion 0.543140
## Condition:Emotion 0.623498
## talkergroup_final:Condition:Emotion 0.510256
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
AIC(model1)
## [1] 2397.326
model1 <- lmer(accuracy ~ talkergroup_final*Condition*Emotion*MeanAmp_P3 + calculator_age_cve + (1|Subject),
data = final_merged)
anova(model1)
## Type III Analysis of Variance Table with Satterthwaite's method
## Sum Sq Mean Sq NumDF DenDF
## talkergroup_final 408.6 408.6 1 244.957
## Condition 4223.6 4223.6 1 228.392
## Emotion 60.4 60.4 1 225.257
## MeanAmp_P3 4.8 4.8 1 289.508
## calculator_age_cve 557.4 557.4 1 74.805
## talkergroup_final:Condition 209.6 209.6 1 231.550
## talkergroup_final:Emotion 179.5 179.5 1 224.332
## Condition:Emotion 148.3 148.3 1 224.166
## talkergroup_final:MeanAmp_P3 8.4 8.4 1 282.984
## Condition:MeanAmp_P3 5.4 5.4 1 253.784
## Emotion:MeanAmp_P3 737.2 737.2 1 248.298
## talkergroup_final:Condition:Emotion 193.3 193.3 1 224.871
## talkergroup_final:Condition:MeanAmp_P3 3.9 3.9 1 257.942
## talkergroup_final:Emotion:MeanAmp_P3 410.1 410.1 1 254.016
## Condition:Emotion:MeanAmp_P3 249.5 249.5 1 247.997
## talkergroup_final:Condition:Emotion:MeanAmp_P3 76.1 76.1 1 249.498
## F value Pr(>F)
## talkergroup_final 4.3969 0.037030 *
## Condition 45.4472 1.267e-10 ***
## Emotion 0.6501 0.420933
## MeanAmp_P3 0.0513 0.821019
## calculator_age_cve 5.9983 0.016661 *
## talkergroup_final:Condition 2.2556 0.134497
## talkergroup_final:Emotion 1.9312 0.166002
## Condition:Emotion 1.5954 0.207870
## talkergroup_final:MeanAmp_P3 0.0901 0.764208
## Condition:MeanAmp_P3 0.0580 0.809844
## Emotion:MeanAmp_P3 7.9321 0.005247 **
## talkergroup_final:Condition:Emotion 2.0797 0.150658
## talkergroup_final:Condition:MeanAmp_P3 0.0416 0.838564
## talkergroup_final:Emotion:MeanAmp_P3 4.4131 0.036651 *
## Condition:Emotion:MeanAmp_P3 2.6844 0.102605
## talkergroup_final:Condition:Emotion:MeanAmp_P3 0.8190 0.366337
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
plot1 <- plot_model(model1, type='pred', terms = c("MeanAmp_P3", "Emotion", "talkergroup_final")) + aes(linetype = group, color = group) +
theme_bw() +
labs(x = "Mean P3 Amplitude (Scaled)", y = "Accuracy (%)", fill = "talkergroup_final")+
theme(axis.title.x = element_text(family="Arial", color = "grey20", size = 14, angle = 0),
axis.title.y = element_text(family="Arial", color = "grey20", size = 14, angle = 90),
axis.text.x = element_text(family="Arial", color = "grey20", size = 12, angle = 0),
axis.text.y = element_text(family="Arial", color = "grey20", size = 12, angle = 0),
legend.text = element_text(family="Arial", color = "grey20", size = 12, angle = 0),
title = element_blank(),
legend.title = element_blank())+
scale_color_manual(values = c("mediumpurple1", "springgreen3"), labels = c("Neutral", "Affective")) +
scale_fill_manual(values = c("mediumpurple1", "springgreen3"), labels = c("Neutral", "Affective"))
## Scale for colour is already present.
## Adding another scale for colour, which will replace the existing scale.
print(plot1)
#FIT MULTIPLE LINEAR MODELS FOR EACH TALKERGROUP AND EMOTION
# Create an empty data frame to store the results
results_df <- data.frame(
Emotion = character(),
TalkerGroup = character(),
P_Value = numeric(),
stringsAsFactors = FALSE
)
# Create a subset of your data for each combination of emotion and talkergroup
subsets <- final_merged %>%
filter(Emotion %in% c(0,1), talkergroup_final %in% c(0, 1))
# Loop through each combination and extract the p-values
for (emotion in unique(subsets$Emotion)) {
for (group in unique(subsets$talkergroup_final)) {
subset_data <- subsets %>%
filter(Emotion == emotion, talkergroup_final == group)
# Fit a linear regression model for the current combination
model <- lm(accuracy ~ MeanAmp_P3, data = subset_data)
# Extract the p-value
p_value <- summary(model)$coefficients[2, 4] # Assumes MeanAmp_P3 is the second coefficient
# Create a data frame with the results
result_row <- data.frame(
Emotion = emotion,
TalkerGroup = paste("talkergroup", group),
P_Value = p_value
)
# Append the results to the results data frame
results_df <- rbind(results_df, result_row)
}
}
# Print the results
print(results_df)
## Emotion TalkerGroup P_Value
## 1 1 talkergroup 1 0.52452700
## 2 1 talkergroup 0 0.06758877
## 3 0 talkergroup 1 0.58951614
## 4 0 talkergroup 0 0.78517833
ZOO_Corr_NoGo_Neg_CWS <- subset(ZOO_FCz_Pz, Condition == "NoGo" & Emotion == "Neg" & talkergroup_final == 1)
ZOO_Corr_NoGo_Neut_CWS <- subset(ZOO_FCz_Pz, Condition == "NoGo" & Emotion == "Neut" & talkergroup_final == 1)
ZOO_Corr_Go_Neg_CWS <- subset(ZOO_FCz_Pz, Condition == "Go" & Emotion == "Neg" & talkergroup_final == 1)
ZOO_Corr_Go_Neut_CWS <- subset(ZOO_FCz_Pz, Condition == "Go" & Emotion == "Neut" & talkergroup_final == 1)
ZOO_Corr_NoGo_Neg_CWNS <- subset(ZOO_FCz_Pz, Condition == "NoGo" & Emotion == "Neg" & talkergroup_final == 0)
ZOO_Corr_NoGo_Neut_CWNS <- subset(ZOO_FCz_Pz, Condition == "NoGo" & Emotion == "Neut" & talkergroup_final == 0)
ZOO_Corr_Go_Neg_CWNS <- subset(ZOO_FCz_Pz, Condition == "Go" & Emotion == "Neg" & talkergroup_final == 0)
ZOO_Corr_Go_Neut_CWNS <- subset(ZOO_FCz_Pz, Condition == "Go" & Emotion == "Neut" & talkergroup_final == 0)
rownames(ZOO_Corr_NoGo_Neg_CWS) <- NULL
rownames(ZOO_Corr_NoGo_Neut_CWS) <- NULL
rownames(ZOO_Corr_Go_Neg_CWS) <- NULL
rownames(ZOO_Corr_Go_Neut_CWS) <- NULL
rownames(ZOO_Corr_NoGo_Neg_CWNS) <- NULL
rownames(ZOO_Corr_NoGo_Neut_CWNS) <- NULL
rownames(ZOO_Corr_Go_Neg_CWNS) <- NULL
rownames(ZOO_Corr_Go_Neut_CWNS) <- NULL
#DRAW CORRELATION PLOTS###########################
correlation_analysis <- function(df1, df2, var1, var2) {
# Perform the correlation test
correlation_CWS <- cor.test(df1[[var1]], df1[[var2]], use="complete.obs") #exclude pairs with missing values
correlation_CWNS <- cor.test(df2[[var1]], df2[[var2]], use="complete.obs")
# Create a scatter plot with a regression line and confidence interval
# use `aes_string()` or aes with !!sym when you're passing variable names as strings.
title <- paste(deparse(substitute(df1)), "and", deparse(substitute(df2)))
ggplot() +
geom_point(data = df1, aes(x = !!sym(var1), y = !!sym(var2)), color = "red") +
geom_smooth(data = df1, aes(x = !!sym(var1), y = !!sym(var2)), method = "lm", se = TRUE, col = "red") +
geom_point(data = df2, aes(x = !!sym(var1), y = !!sym(var2)), color = "blue") +
geom_smooth(data = df2, aes(x = !!sym(var1), y = !!sym(var2)), method = "lm", se = TRUE, col = "blue") +
labs(title = title, x = "ERP Amplitude (µV)", y = "Accuracy (%)") +
theme_minimal() + # Set background to white
theme(panel.grid.major = element_blank(), # Remove major grid lines
panel.grid.minor = element_blank(), # Remove minor grid lines
axis.line = element_line(color = "black"),
axis.text = element_text(size = 14), # Increase font size for both axis labels and tick labels
axis.title = element_text(size = 16)) + # Increase font size for axis labels
ylim(40, 110) + # Replace ymin_value and ymax_value with your desired limits
annotate("text", x = mean(df1[[var1]]), y = max(df1[[var2]]) + 5,
label = paste("CWS r =", round(correlation_CWS$estimate, 3)), vjust = -1, col = "red") +
annotate("text", x = mean(df1[[var1]]), y = max(df1[[var2]]),
label = paste("p-value =", round(correlation_CWS$p.value, 3)), vjust = -1, col = "red") +
annotate("text", x = mean(df2[[var1]]), y = min(df2[[var2]]) + 5,
label = paste("CWNS r =", round(correlation_CWNS$estimate, 3)), vjust = -1, col = "blue") +
annotate("text", x = mean(df2[[var1]]), y = min(df2[[var2]]),
label = paste("p-value =", round(correlation_CWNS$p.value, 3)), vjust = -1, col = "blue") +
theme(legend.position = "none")
}
correlation_analysis(ZOO_Corr_NoGo_Neg_CWS, ZOO_Corr_NoGo_Neg_CWNS, "MeanAmp_N2P2", "accuracy")
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'
correlation_analysis(ZOO_Corr_NoGo_Neut_CWS, ZOO_Corr_NoGo_Neut_CWNS, "MeanAmp_N2P2", "accuracy")
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'
correlation_analysis(ZOO_Corr_Go_Neg_CWS, ZOO_Corr_Go_Neg_CWNS, "MeanAmp_N2P2", "accuracy")
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'
correlation_analysis(ZOO_Corr_Go_Neut_CWS, ZOO_Corr_Go_Neut_CWNS, "MeanAmp_N2P2", "accuracy")
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'
correlation_analysis(ZOO_Corr_NoGo_Neg_CWS, ZOO_Corr_NoGo_Neg_CWNS, "MeanAmp_P3", "accuracy")
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'
correlation_analysis(ZOO_Corr_NoGo_Neut_CWS, ZOO_Corr_NoGo_Neut_CWNS, "MeanAmp_P3", "accuracy")
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'
correlation_analysis(ZOO_Corr_Go_Neg_CWS, ZOO_Corr_Go_Neg_CWNS, "MeanAmp_P3", "accuracy")
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'
correlation_analysis(ZOO_Corr_Go_Neut_CWS, ZOO_Corr_Go_Neut_CWNS, "MeanAmp_P3", "accuracy")
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'
#PERSONALIZED PLOT######
correlation_CWNS_Neg_GO <- cor.test(ZOO_Corr_NoGo_Neg_CWS$MeanAmp_P3, ZOO_Corr_NoGo_Neg_CWS$accuracy)
correlation_CWNS_Neg_NOGO <- cor.test(ZOO_Corr_NoGo_Neg_CWNS$MeanAmp_P3, ZOO_Corr_NoGo_Neg_CWNS$accuracy)
# Create a scatter plot with a regression line and confidence interval
ggplot() +
geom_point(data = ZOO_Corr_NoGo_Neg_CWS, aes(x = MeanAmp_P3, y = accuracy), color = "blue") +
geom_smooth(data = ZOO_Corr_NoGo_Neg_CWS, aes(x = MeanAmp_P3, y = accuracy), method = "lm", se = TRUE, col = "blue") +
geom_point(data = ZOO_Corr_NoGo_Neg_CWNS, aes(x = MeanAmp_P3, y = accuracy), color = "red") +
geom_smooth(data = ZOO_Corr_NoGo_Neg_CWNS, aes(x = MeanAmp_P3, y = accuracy), method = "lm", se = TRUE, col = "red") +
labs(title = "CWNS in Affective GO and NOGO", x = "P3 Amplitude (µV)", y = "Accuracy (%)") +
theme_minimal() + # Set background to white
theme(panel.grid.major = element_blank(), # Remove major grid lines
panel.grid.minor = element_blank(), # Remove minor grid lines
axis.line = element_line(color = "black"),
axis.text = element_text(size = 14), # Increase font size for both axis labels and tick labels
axis.title = element_text(size = 16)) + # Increase font size for axis labels
ylim(40, 110) + # Replace ymin_value and ymax_value with your desired limits
annotate("text", x = mean(ZOO_Corr_NoGo_Neg_CWS$MeanAmp_P3), y = max(ZOO_Corr_NoGo_Neg_CWS$accuracy) + 5,
label = paste("Affective GO r =", round(correlation_CWNS_Neg_GO$estimate, 3)), vjust = -1, col = "blue") +
annotate("text", x = mean(ZOO_Corr_NoGo_Neg_CWS$MeanAmp_P3), y = max(ZOO_Corr_NoGo_Neg_CWS$accuracy),
label = paste("p-value =", round(correlation_CWNS_Neg_GO$p.value, 3)), vjust = -1, col = "blue") +
annotate("text", x = mean(ZOO_Corr_NoGo_Neg_CWNS$MeanAmp_P3), y = min(ZOO_Corr_NoGo_Neg_CWNS$accuracy) + 5,
label = paste("Affective NOGO r =", round(correlation_CWNS_Neg_NOGO$estimate, 3)), vjust = -1, col = "red") +
annotate("text", x = mean(ZOO_Corr_NoGo_Neg_CWNS$MeanAmp_P3), y = min(ZOO_Corr_NoGo_Neg_CWNS$accuracy),
label = paste("p-value =", round(correlation_CWNS_Neg_NOGO$p.value, 3)), vjust = -1, col = "red") +
theme(legend.position = "none")
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'